home *** CD-ROM | disk | FTP | other *** search
-
-
-
- Handles C Library Procedures Handles
-
-
-
- _________________________________________________________________
-
- NNAAMMEE
- Tcl_HandleAlloc, Tcl_HandleFree, Tcl_HandleTblInit,
- Tcl_HandleTblRelease, Tcl_HandleTblUseCount Tcl_HandleWalk,
- Tcl_HandleXlate - Dynamic, handle addressable tables.
-
-
- SSYYNNOOPPSSIISS
- ##iinncclluuddee <<ttccllEExxtteenndd..hh>>
-
- void_pt
- TTccll__HHaannddlleeTTbbllIInniitt (_h_a_n_d_l_e_B_a_s_e, _e_n_t_r_y_S_i_z_e, _i_n_i_t_E_n_t_r_i_e_s)
-
- int
- TTccll__HHaannddlleeTTbbllUUsseeCCoouunntt (_h_e_a_d_e_r_P_t_r, _a_m_o_u_n_t)
-
- void
- TTccll__HHaannddlleeTTbbllRReelleeaassee (_h_e_a_d_e_r_P_t_r)
-
- void_pt
- TTccll__HHaannddlleeAAlllloocc (_h_e_a_d_e_r_P_t_r, _h_a_n_d_l_e_P_t_r)
-
- void
- TTccll__HHaannddlleeFFrreeee (_h_e_a_d_e_r_P_t_r, _e_n_t_r_y_P_t_r)
-
- void_pt
- TTccll__HHaannddlleeWWaallkk (_h_e_a_d_e_r_P_t_r, _w_a_l_k_K_e_y_P_t_r)
-
- void
- TTccll__WWaallkkKKeeyyTTooHHaannddllee (_h_e_a_d_e_r_P_t_r, _w_a_l_k_K_e_y, _h_a_n_d_l_e_P_t_r)
-
- void_pt
- TTccll__HHaannddlleeXXllaattee (_i_n_t_e_r_p, _h_e_a_d_e_r_P_t_r, _h_a_n_d_l_e)
-
- AARRGGUUMMEENNTTSS
- char *_h_a_n_d_l_e_B_a_s_e (in) Base name for the han-
- dle, numeric entry
- number will be
- appended.
-
- int _e_n_t_r_y_S_i_z_e (in) Size of the table
- entries, in bytes.
-
- int _i_n_i_t_E_n_t_r_i_e_s (in) Initial number of
- entries to allocate.
-
- int _a_m_o_u_n_t (in) Amount to alter the use
- count by.
-
- void_pt _h_e_a_d_e_r_P_t_r (in) Pointer to the header.
-
-
-
-
- Sprite v1.0 1
-
-
-
-
-
-
- Handles C Library Procedures Handles
-
-
-
- char *_h_a_n_d_l_e_P_t_r (out) The handle name is
- returned here. It must
- be large enough to hold
- the handle base name
- with a number appended.
-
- Tcl_Interp *_i_n_t_e_r_p (in) Interpreter to use for
- error reporting.
-
- char *_h_a_n_d_l_e (in) Name of handle to
- operate on.
-
- void_pt _e_n_t_r_y_P_t_r (in) Pointer to a handle
- table entry.
-
- int *_w_a_l_k_K_e_y_P_t_r (i/o) Key used to walk the
- table, initialize to -1
- before the first call.
-
- int _w_a_l_k_K_e_y (in) Key returned from walk-
- ing the table.
- _________________________________________________________________
-
-
- DDEESSCCRRIIPPTTIIOONN
- The Tcl handle facility provides a way to manage table
- entries that may be referenced by a textual handle from Tcl
- code. This is provided for applications that need to create
- data structures in one command, return a reference (i.e.
- pointer) to that particular data structure and then access
- that data structure in other commands. An example applica-
- tion is file handles.
-
- A handle consists of a base name, which is some unique,
- meaningful name, such as `ffiillee' and a numeric value appended
- to the base name (e.g. `file3'). The handle facility is
- designed to provide a standard mechanism for building Tcl
- commands that allocate and access table entries based on an
- entry index. The tables are expanded when needed, conse-
- quently pointers to entries should not be kept, as they will
- become invalid when the table is expanded. If the table
- entries are large or pointers must be kept to the entries,
- then the the entries should be allocated separately and
- pointers kept in the handle table. A use count is kept on
- the table. This use count is intended to determine when a
- table shared by multiple commands is to be release.
-
- TTccll__HHaannddlleeTTbbllIInniitt creates and initialize a Tcl dynamic han-
- dle table. The specified initial number of entries will be
- allocated and added to the free list. The use count will be
- set to one.
-
-
-
-
- Sprite v1.0 2
-
-
-
-
-
-
- Handles C Library Procedures Handles
-
-
-
- TTccll__HHaannddlleeTTbbllUUsseeCCoouunntt alters the use count on a table and
- returns the new value. The use count has _a_m_o_u_n_t added to
- it, where _a_m_o_u_n_t may be positive, zero or negative. A zero
- value retrieves the current use count. This is normally
- used to increment the use count when multiple commands are
- sharing the table.
-
- TTccll__HHaannddlleeTTbbllRReelleeaassee decrements the use count on a table. If
- it becomes zero (or negative), the the table will be
- released. Note that no clean up is done on the table entry
- client supplied data. If clean up must be done, then
- TTccll__HHaannddlleeTTbbllUUsseeCCoouunntt can be used to decrement the use
- count. When it goes to zero, the table may be walked and
- then released. _H_e_a_d_e_r_P_t_r is declared as CClliieennttDDaattaa so that
- the procedure may be passed as a command deletion procedure.
-
- TTccll__HHaannddlleeAAlllloocc allocates an entry and associates a handle
- with it. The handle is returned to the buffer pointed to by
- _h_a_n_d_l_e_P_t_r can then be used to access the entry. The buffer
- must be large enough to accommodate the base handle name
- with 2 to 4 digits appended along with a terminating null
- byte. A pointer is returned to the allocated entry. If
- TTccll__HHaannddlleeFFrreeee has not been called since initialization,
- handles will be handed out sequentially from zero. This
- behavior is useful in setting up initial entries, such as
- ``ssttddiinn'' for a file table.
-
- TTccll__HHaannddlleeXXllaattee translates a handle to a pointer to the
- corresponding table entry. If the handle is not allocated
- (open) or is invalid, NULL is returned and an error message
- is set in _i_n_t_e_r_p->_r_e_s_u_l_t.
-
- TTccll__HHaannddlleeWWaallkk walks through and finds every allocated entry
- in a table. Entries may be deallocated during a walk, but
- should not be allocated. TTccll__HHaannddlleeWWaallkk will return a
- pointer to the entry, or NULL if no more entries are avail-
- able. The integer pointed to by wwaallkkKKeeyyPPttrr should be set to
- `-1' before the first call, and then the pointer passed to
- each subsequent call left unmodified.
-
- TTccll__WWaallkkKKeeyyTTooHHaannddllee converts a walk key, as returned from a
- call to TTccll__HHaannddlleeWWaallkk into a handle.
-
- TTccll__HHaannddlleeFFrreeee frees a handle table entry.
-
- KKEEYYWWOORRDDSS
- handle, table, allocate
-
-
-
-
-
-
-
-
- Sprite v1.0 3
-
-
-
-